package com.kmxd.ams.app.event.archive;

import com.kmxd.ams.app.event.archive.command.CopyFondsCmd;
import com.kmxd.ams.client.event.archive.CopyArchTypeEvent;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * 档案门类复制
 *
 * @author ZuoLG
 */
@Slf4j
@Component
@AllArgsConstructor
public class CopyArchTypeListener {

  private final CopyFondsCmd copyFondsCmd;

  /**
   * 实现复制功能
   *
   * @param event
   */
  @SneakyThrows
  @TransactionalEventListener(fallbackExecution = true)
  public void initCopy(CopyArchTypeEvent event) {
    copyFondsCmd.initCopy(event.getEntity(), event.getReq());
  }
}
